/*
 * Copyright (c) 2023, mr-library Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2023-04-23     MacRsh       first version
 */

#include "drv_lcd.h"
#include "lvgl.h"
#include "monitor.h"

#if defined(MR_CFG_LCD)

static struct mr_lcd lcd_device[1];

static mr_err_t sim_lcd_configure(mr_lcd_t lcd, struct mr_lcd_config *config)
{
    return MR_ERR_OK;
}

static void sim_lcd_write(mr_lcd_t lcd, void *disp_drv, void *area, void *color_p)
{
#if !MONITOR_DUAL
    monitor_flush(disp_drv, area, color_p);
#else
    monitor_flush2(disp_drv, area, color_p);
#endif
    return;
}

static mr_uint8_t sim_lcd_read(mr_lcd_t lcd)
{
    return 0;
}

mr_err_t drv_lcd_init(void)
{
    static struct mr_lcd_ops drv_ops =
        {
            sim_lcd_configure,
            sim_lcd_write,
            sim_lcd_read,
        };

    mr_err_t ret = MR_ERR_OK;
    ret = mr_lcd_device_add(&lcd_device[0], MR_CFG_LCD_NAME, &drv_ops, NULL);
    MR_ASSERT(ret == MR_ERR_OK);

    return ret;
}
MR_INIT_DRIVER_EXPORT(drv_lcd_init);

#endif
